package com.prince.enums;

import com.prince.entity.TagItemSimpleVo;

import java.util.ArrayList;
import java.util.List;
/**
 * 功能描述: 销售记录
 * @Author: 王培喜 58528792@163.com
 * @Date: 2021/4/6 15:25
 */
public enum SaleEnum {
    /** 售记录 */
    ADD(1,"销售"),
    SUBTRACT(2,"退款");


    private Integer code;
    private String name;
    SaleEnum(Integer code , String name){
        this.code = code;
        this.name = name;
    }
    public Integer getCode(){
        return code;
    }
    public String getName(){
        return name;
    }
    /**
     * Description: 获取枚举转换成的列表数据
     * @author 王培喜(58528792@163.com)
     * @date  2020/6/24 16:39
     * @return List<TagItemSimpleVo>
     */
    public static List<TagItemSimpleVo> getListData() {
        List<TagItemSimpleVo> list = new ArrayList<>();
        for (SaleEnum value : values()) {
            list.add(new TagItemSimpleVo(String.valueOf(value.getCode()),value.getName()));
        }
        return list;
    }
    /**
     * Description: 获取枚举名称
     * @author 王培喜(58528792@163.com)
     * @date  2020/6/24 16:39
     * @return List<TagItemSimpleVo>
     */
    public static String getName(Integer code){
        for (SaleEnum value : values()) {
            if(code.equals(value.code)){
                return value.name;
            }
        }
        return "";
    }

}
